//
// Created by wenyaxi on 24-10-29.
//

#include <common.h>

class Solution {
public:
    vector<char> stk;

    bool isValid(string s) {
        for (auto &c: s) {
            if (stk.empty()) {
                stk.push_back(c);
            } else {
                if (stk[stk.size() - 1] == '(' && c == ')') {
                    stk.pop_back();
                } else if (stk[stk.size() - 1] == '{' && c == '}') {
                    stk.pop_back();
                } else if (stk[stk.size() - 1] == '[' && c == ']') {
                    stk.pop_back();
                } else {
                    stk.push_back(c);
                }
            }
        }
        return stk.empty();
    }
};

int main(int argc, char *argv[]) {
    Solution s;
    cout << s.isValid("()[]{}");
    return 0;
}
